// pages/logs/logs3/logs3.js
const app = getApp();
const config = require("../../../utils/config.js");
const request = require('../../../utils/request.js');

Page({

  /**
   * 页面的初始数据
   */
  data: {
    testColor: 'black',
    brandColor:'black',
    crowdColor:'black',
    neiBackground:'#f8f8f8',
    fenge:['时尚','商务','休闲','简约','运动','复古'],
    biaodai: ['牛皮','不锈钢','鳄鱼皮','镀金','陶瓷','橡胶'],
    jixin: ['牛皮','不锈钢','石英表','光能表'],
    pinpai: ['BEGEEL','Cartier','fiyta','Longines','TAG Heuer'],
    chandi:['中国','瑞士','德国','日本','其他产地'],
    list:[],
    anima:'',
    screenAnima:'',
    screenRight:'-100%',
    ID:1,
    isclick:false,
    isshow:true,
    value:'',
    sear:[]
  },
  liebiaoBind:function(e){
    wx.navigateTo({
      url: '../details/details?id=' + this.data.list[e.currentTarget.dataset.index].id,
    })
    
    console.log(e.currentTarget.dataset.index)
  },
  getData:function () {
    var that = this;
    request.request(config.list, 'GET', {}, function (res) {
      console.log(res);
      that.setData({
        list:res.data.data.data
      })
    })
  },
  change:function(e){
    this.setData({
      value:e.detail.value
    })
  },
  searchBut: function (e) {
    var list = this.data.list;
    this.data.sear = [];
    for (var i = 0; i < this.data.list.length; i++) {
      if (this.data.value != "" && this.data.list[i].name.indexOf(this.data.value) != -1) {
        console.log(this.data.list[i].name);
        this.data.sear.push(this.data.list[i]);
      }
    }
    if (this.data.value != "" && this.data.value != null && this.data.value != this.data.valueCopy) {
      this.setData({
        list: this.data.sear,
        valueCopy: this.data.value
      })
    }
    console.log(this.data.sear)
  },
  // 点击筛选动画
  screenBind:function(){
    console.log(this.data.isclick)
    if(this.data.isclick==false){
      this.pop = wx.createAnimation({
        duration: 100,
        timingFunction: "linear",
        delay: 0,
      })
      this.pop.right(0).step();
      this.setData({
        screenAnima: this.pop.export(),
        isclick:true
      })
    }else{
      this.sBind()
      this.setData({
        isclick:false
      })
    }
  },
  sBind:function(){
    this.pop = wx.createAnimation({
      duration: 100,
      timingFunction: "linear",
      delay: 0,
    })
    this.pop.right('-100%').step();
    this.setData({
      screenAnima:this.pop.export()
    })
  },
  // 点击改变租价颜色
  testBind: function () {
    if (this.data.testColor=="black"){
      this.setData({
        testColor: 'red',
        crowdColor: 'black',
        brandColor: 'black'
      })
    }else{
      this.setData({
        testColor: 'black'
      })
    }
  },
  // 点击改变人群颜色
  crowdBind: function () {
    if (this.data.crowdColor == "black") {
      this.setData({
        crowdColor: 'red',
        testColor: 'black',
        brandColor: 'black'
      })
    } else {
      this.setData({
        crowdColor: 'black'
      })
    }
  },
  // 点击改变品牌颜色
  brandBind: function () {
    if (this.data.brandColor == "black") {
      this.setData({
        brandColor: 'red',
        crowdColor: 'black',
        testColor: 'black'
      })
    } else {
      this.setData({
        brandColor: 'black',
       
      })
    }
  },
  //点击改变爱心样式
  // xin1Bind:function(e){
  //   console.log(e)
  //   this.pop = wx.createAnimation({
  //     duration: 100,
  //     delay: 0
  //   })
  //   this.pop.scale(1).step();
  //   this.setData({
  //     anima: this.pop.export()
  //   })
  //   if(this.data.isshow==true){
  //     this.setData({
  //       isshow:false
  //     })
  //   }else{
  //     this.setData({
  //       isshow: true
  //     })
  //   }
  // },
  // xin2Bind:function(){
  //   this.pop.scale(0).step({
  //     duration: 100,
  //     delay: 0
  //   });
  //   this.setData({
  //     anima: this.pop.export()
  //   })
  // },
  // 点击改变背景颜色
  fengeBind:function(e){
    // if (this.data.neiBackground == "#f8f8f8") {
    //   this.setData({
    //     neiBackground: '#cccccc',
    //   })
    // } else {
    //   this.setData({
    //     neiBackground: '#f8f8f8',

    //   })
    // }
    
  
    console.log(e.currentTarget.dataset.index)
  },
  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function (options) {
    
  },

  /**
   * 生命周期函数--监听页面初次渲染完成
   */
  onReady: function () {
    
  },

  /**
   * 生命周期函数--监听页面显示
   */
  onShow: function () {
    this.getData();
    
  },

  /**
   * 生命周期函数--监听页面隐藏
   */
  onHide: function () {

  },

  /**
   * 生命周期函数--监听页面卸载
   */
  onUnload: function () {

  },

  /**
   * 页面相关事件处理函数--监听用户下拉动作
   */
  onPullDownRefresh: function () {

  },

  /**
   * 页面上拉触底事件的处理函数
   */
  onReachBottom: function () {

  },

  /**
   * 用户点击右上角分享
   */
  onShareAppMessage: function () {

  }
})